; Music of Ninja Hamster (1987) (CRL)
; Ripped by Megachur the 06/04/2008

	write "NINJAHAM.BIN"

music_date_rip	equ &0648
music_adr	equ &5600
first_theme	equ 0
last_theme	equ 0

	read "music_header_v1_0.asm"

;&5600
	
;
.play_music
;
	ld a,(l56b2)
	dec a
	jp z,l57d0
	ld (l56b2),a
	ret
;
.real_init_music
;
	ld hl,l2000
	ld (l56b8),hl
	ld hl,l2169
	ld (l56ba),hl
	ld hl,l2342
	ld (l56bc),hl
	xor a
	ld (l56b5),a
	ld (l56b6),a
	ld (l56b7),a
	inc a
	ld (l56b2),a
	ld (l56b3),a
	ld a,#01
	ld (l5655),a
.l5633
	ld d,#00
	ld a,(l5655)
	sla a
	ld e,a
	ld hl,l5656
	add hl,de
	ld e,(hl)
	inc hl
	ld d,(hl)
	ex de,hl
	ld a,(l5655)
	call #bcbc
	ld a,(l5655)
	inc a
	ld (l5655),a
	cp #10
	jr c,l5633
	ret
.l5656 equ $ + 1
.l5655
	db #00,#00,#00
	dw l5676,l567a,l567e,l5682
	dw l5686,l568a,l56ae,l568e
	dw l5692,l56aa,l5696,l569a
	dw l569e,l56a2,l56a6
.l567a equ $ + 4
.l5676
	db #01,#0f,#ff,#02,#01,#0f,#ff,#0a
.l5682 equ $ + 4
.l567e
	db #01,#0f,#ff,#0a,#01,#01,#ff,#05
.l568a equ $ + 4
.l5686
	db #01,#0f,#ff,#06,#01,#0f,#ff,#06
.l5692 equ $ + 4
.l568e
	db #01,#0f,#ff,#06,#01,#0f,#ff,#06
.l569a equ $ + 4
.l5696
	db #01,#0f,#ff,#0f,#01,#0f,#ff,#06
.l56a2 equ $ + 4
.l569e
	db #01,#0f,#ff,#06,#01,#0f,#ff,#06
.l56aa equ $ + 4
.l56a6
	db #01,#0c,#ff,#06,#01,#0a,#ff,#0a
.l56b5 equ $ + 7
.l56b4 equ $ + 6
.l56b3 equ $ + 5
.l56b2 equ $ + 4
.l56ae
	db #01,#0f,#ff,#06,#01,#01,#00,#00
.l56b8 equ $ + 2
.l56b7 equ $ + 1
.l56b6
	db #00,#00,#00
.l56c0 equ $ + 7
.l56bf equ $ + 6
.l56be equ $ + 5
.l56bc equ $ + 3
.l56ba equ $ + 1
	db #00,#00,#00,#00,#00,#00,#00,#e0
.l56c1
	db #81,#01,#00,#01,#01,#00,#0f,#00
.l56ca equ $ + 1
	db #00,#82,#01,#00,#00,#00,#00,#0f
.l56d3 equ $ + 2
	db #00,#00,#84,#01,#00,#00,#00,#00
.l56e0 equ $ + 7
.l56df equ $ + 6
.l56dd equ $ + 4
.l56dc equ $ + 3
	db #0f,#00,#00,#00,#00,#00,#00,#00
.l56e3 equ $ + 2
.l56e2 equ $ + 1
.l56e1
	db #00,#00,#00,#00
.l56e5
	dw l2066,l21df,l2345,l2066
	dw l21df,l2345,l2000,l2169
	dw l2342,l2000,l2169,l2342
.l5700 equ $ + 3
.l56ff equ $ + 2
.l56fe equ $ + 1
.l56fd
	dw #0000,#0000
.l5701
	ld hl,(l56be)
	xor a
	ld (l56b4),a
	ld a,(hl)
	and #80
	jp z,l5784
	ld a,(hl)
	and #f0
	cp #c0
	jp z,l576c
	cp #b0
	jp nz,l5727
	ld a,(hl)
	ld (l56b3),a
	and #0f
	ld (l56b2),a
	jp l576c
.l5727
	cp #d0
	jr nz,l573d
	ld a,(hl)
	and #0f
	inc a
	cp #10
	jr nz,l5734
	dec a
.l5734
	ld (l5700),a
	inc hl
	ld (l56be),hl
	jr l5701
.l573d
	cp #e0
	jp nz,l5776
	ld d,(hl)
	ld a,(l56c0)
	cp d
	jr nz,l576c
	and #0f
	sla a
	ld d,#00
	ld e,a
	ld hl,l56e5
	add hl,de
	ld a,(hl)
	ld (l56be),a
	inc hl
	ld a,(hl)
	ld (l56bf),a
	ld hl,l56c0
	inc (hl)
	ld a,(hl)
	cp #e9
	jp nz,l5701
	ld (hl),#e0
	jp l5701
.l576c
	ld hl,(l56be)
	inc hl
	ld (l56be),hl
	jp l5701
.l5776
	ld a,(hl)
	cp #82
	ret nz
	inc hl
	ld a,(hl)
	ld (l56be),hl
	dec a
	ld (l56b4),a
	ret
.l5784
	ld d,#00
	ld e,(hl)
	ld hl,l24d2
	add hl,de
	ld a,(hl)
	ld (l56e0),a
	ld hl,l2452
	add hl,de
	ld a,(hl)
	ld (l56df),a
	ld a,(l5700)
	ld (l56dd),a
	xor a
	ld (l56e1),a
	ld (l56e3),a
	ld a,#0f
	ld (l56e2),a
	ld a,(l5700)
	cp #01
	jr z,l57ca
	cp #05
	jr nc,l57ca
	ld a,(l56df)
	or #02
	and #1f
	ld (l56e1),a
	ld a,#0b
	ld (l56e2),a
	ld de,#0000
	ld (l56df),de
.l57ca
	ld hl,l56dc
	jp #bcaa
.l57d0
	ld a,(l56b3)
	and #0f
	ld (l56b2),a
	ld a,(l56b5)
	or a
	jp z,l57e6
	dec a
	ld (l56b5),a
	jp l5801
.l57e6
	ld hl,(l56b8)
	ld a,(l56fd)
	ld (l56be),hl
	ld hl,l56c1
	call l5852
	ld (l56fd),a
	ld a,(l56b4)
	ld (l56b5),a
	ld (l56b8),hl
.l5801
	ld a,(l56b6)
	or a
	jp z,l580f
	dec a
	ld (l56b6),a
	jp l582a
.l580f
	ld hl,(l56ba)
	ld a,(l56fe)
	ld (l56be),hl
	ld hl,l56ca
	call l5852
	ld (l56fe),a
	ld a,(l56b4)
	ld (l56b6),a
	ld (l56ba),hl
.l582a
	ld a,(l56b7)
	or a
	jp z,l5836
	dec a
	ld (l56b7),a
	ret
.l5836
	ld hl,(l56bc)
	ld (l56be),hl
	ld a,(l56ff)
	ld hl,l56d3
	call l5852
	ld (l56ff),a
	ld a,(l56b4)
	ld (l56b7),a
	ld (l56bc),hl
	ret
.l5852
	ld (l5700),a
	ld de,l56dc
	ld bc,#0009
	ldir
	call l5701
	ld hl,(l56be)
	inc hl
	ld (l56be),hl
	ld a,(l5700)
	ret
	
;org #2000
.l2000
	db #b7,#d0,#df,#5a,#80,#58,#80,#56
	db #58,#56,#80,#53,#56,#53,#51,#53
	db #80,#4a,#80,#53,#56,#53,#51,#53
	db #80,#46,#80,#48,#41,#48,#46,#48
	db #80,#80,#80,#e6,#d7,#23,#23,#26
	db #23,#2a,#28,#26,#28,#23,#23,#26
	db #23,#2a,#28,#26,#28,#1a,#1a,#21
	db #1a,#26,#25,#23,#25,#1a,#1a,#21
	db #1a,#26,#25,#23,#25,#d7,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#1a,#1a
	db #21,#1a,#26,#25,#23,#25,#1a,#1a
.l2066 equ $ + 6
	db #21,#1a,#26,#25,#23,#25,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#1a,#1a
	db #21,#1a,#26,#25,#23,#25,#1a,#1a
	db #21,#1a,#26,#25,#23,#25,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#1a,#1a
	db #21,#1a,#26,#25,#23,#25,#1a,#1a
	db #21,#1a,#26,#25,#23,#25,#28,#28
	db #2b,#28,#31,#2b,#28,#24,#28,#28
	db #2b,#28,#31,#2b,#28,#24,#28,#28
	db #2b,#28,#31,#2b,#28,#24,#28,#28
	db #2b,#28,#31,#2b,#28,#24,#2a,#26
	db #28,#2a,#28,#26,#23,#21,#2a,#26
	db #28,#2a,#28,#26,#23,#21,#2a,#26
	db #28,#2a,#28,#26,#23,#21,#2a,#26
	db #28,#2a,#28,#26,#23,#21,#28,#23
	db #26,#28,#26,#25,#21,#23,#28,#23
	db #26,#28,#26,#25,#25,#21,#28,#23
	db #26,#28,#26,#25,#21,#23,#28,#23
	db #26,#28,#26,#25,#35,#21,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#23,#23
	db #26,#23,#2a,#28,#26,#28,#e0,#2b
	db #26,#2b,#31,#2b,#2a,#28,#2a,#2b
	db #26,#2a,#28,#23,#2a,#28,#26,#2b
	db #26,#2b,#31,#2b,#2a,#28,#2a,#2b
	db #26,#2a,#28,#23,#2a,#28,#26,#2b
	db #26,#2b,#31,#2b,#2a,#28,#2a,#2b
	db #26,#2a,#28,#23,#2a,#28,#26,#25
	db #21,#23,#25,#21,#23,#25,#26,#28
	db #26,#25,#23,#25,#26,#25,#21,#e3
.l2169 equ $ + 1
	db #e6,#df,#56,#80,#53,#80,#51,#53
	db #51,#80,#4a,#51,#4a,#48,#4a,#80
	db #46,#80,#4a,#51,#4a,#48,#4a,#80
	db #41,#80,#43,#46,#43,#4a,#43,#80
	db #80,#80,#e7,#d5,#43,#80,#d3,#59
	db #59,#d1,#49,#80,#49,#80,#d0,#43
	db #43,#3a,#36,#d1,#59,#80,#49,#80
	db #d5,#4a,#80,#d3,#59,#59,#d1,#49
	db #80,#49,#80,#d0,#4a,#4a,#33,#46
	db #d1,#49,#80,#49,#80,#d5,#43,#80
	db #d3,#59,#59,#d1,#49,#80,#49,#80
	db #d0,#43,#43,#3a,#36,#d1,#59,#80
	db #49,#80,#d5,#4a,#80,#d3,#59,#59
	db #d1,#49,#80,#49,#80,#d0,#4a,#4a
.l21df equ $ + 7
	db #33,#46,#d1,#49,#80,#49,#80,#d5
	db #43,#80,#d3,#59,#59,#d1,#49,#80
	db #49,#80,#d0,#43,#43,#3a,#36,#d1
	db #59,#80,#49,#80,#d5,#4a,#80,#d3
	db #59,#59,#d1,#49,#80,#49,#80,#d0
	db #4a,#4a,#33,#46,#d1,#49,#80,#49
	db #80,#d5,#43,#80,#d3,#59,#59,#d1
	db #49,#80,#49,#80,#d0,#43,#43,#3a
	db #36,#d1,#59,#80,#49,#80,#d5,#4a
	db #80,#d3,#59,#59,#d1,#49,#80,#49
	db #80,#d0,#4a,#4a,#33,#46,#d1,#49
	db #80,#49,#80,#d0,#5b,#58,#4b,#48
	db #d1,#59,#80,#49,#80,#d0,#5b,#58
	db #d3,#59,#59,#d1,#59,#80,#49,#80
	db #d0,#5b,#58,#4b,#48,#d3,#59,#59
	db #d1,#49,#80,#d0,#5b,#58,#d3,#59
	db #69,#d1,#59,#80,#49,#80,#d0,#5a
	db #56,#4a,#46,#d3,#59,#69,#d1,#59
	db #80,#d0,#4a,#56,#d3,#59,#59,#d1
	db #59,#80,#d3,#59,#59,#d0,#5a,#56
	db #4a,#46,#d3,#59,#69,#d1,#59,#80
	db #d0,#5a,#56,#d3,#59,#59,#d1,#59
	db #80,#49,#80,#d0,#58,#53,#48,#53
	db #d3,#59,#59,#d1,#49,#80,#d0,#58
	db #53,#d3,#59,#59,#d1,#49,#80,#d3
	db #59,#59,#d3,#69,#62,#59,#62,#d0
	db #56,#51,#46,#41,#d3,#59,#69,#d0
	db #46,#46,#d1,#49,#80,#59,#80,#d5
	db #43,#80,#d3,#59,#59,#d1,#49,#80
	db #49,#80,#d0,#43,#43,#3a,#36,#d1
	db #59,#80,#49,#80,#d5,#43,#80,#d3
	db #59,#59,#d1,#49,#80,#49,#80,#d0
	db #43,#43,#3a,#36,#d1,#59,#80,#49
	db #80,#e1,#df,#56,#d3,#66,#66,#df
	db #56,#d3,#66,#66,#df,#56,#d3,#66
	db #df,#56,#54,#54,#d1,#54,#80,#d3
	db #59,#59,#59,#df,#56,#d3,#66,#66
	db #df,#56,#d3,#66,#66,#df,#56,#d3
	db #66,#da,#54,#81,#81,#80,#d3,#69
	db #62,#59,#52,#df,#56,#d3,#66,#66
	db #df,#56,#d3,#66,#66,#df,#56,#d3
	db #66,#df,#56,#54,#54,#d1,#54,#80
	db #d3,#59,#59,#59,#d0,#45,#41,#45
	db #d1,#49,#80,#49,#80,#d3,#59,#df
	db #53,#51,#51,#4a,#51,#51,#51,#48
.l2345 equ $ + 5
.l2342 equ $ + 2
	db #e4,#e7,#82,#60,#e8,#da,#53,#81
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#80,#df,#5a
	db #5a,#58,#58,#56,#58,#56,#51,#4a
	db #51,#4a,#48,#4a,#51,#56,#51,#53
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#5a
	db #5a,#58,#58,#56,#58,#56,#51,#4a
	db #51,#4a,#48,#4a,#51,#56,#51,#4b
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#5b
	db #61,#5b,#5a,#5b,#5a,#58,#56,#5b
	db #61,#5b,#5a,#5b,#5a,#58,#56,#5a
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#5a
	db #5b,#5a,#58,#56,#58,#5a,#58,#5a
	db #5b,#5a,#58,#56,#58,#56,#53,#58
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#58
	db #5a,#58,#56,#61,#5a,#58,#5a,#58
	db #5a,#58,#56,#55,#56,#55,#51,#53
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#53
	db #81,#81,#81,#81,#81,#81,#81,#81
	db #81,#81,#81,#81,#81,#81,#80,#e2
	db #df,#5b,#5b,#5b,#61,#61,#61,#5b
	db #5b,#5a,#58,#58,#58,#80,#d5,#58
	db #58,#58,#df,#5b,#5b,#5b,#61,#61
	db #61,#5a,#5a,#da,#58,#81,#81,#80
	db #d5,#58,#80,#54,#80,#df,#5b,#5b
	db #5b,#61,#61,#61,#5b,#5b,#5a,#58
	db #58,#58,#80,#d5,#58,#58,#58,#df
	db #55,#55,#55,#56,#56,#56,#55,#55
	db #58,#56,#55,#53,#55,#56,#55,#51
.l2452 equ $ + 2
	db #e5,#e8,#ee,#18,#4d,#8e,#da,#2f
	db #8f,#f7,#68,#e1,#61,#e9,#00,#00
	db #00,#00,#77,#0c,#a7,#47,#ed,#98
	db #47,#fc,#b4,#70,#31,#f4,#00,#00
	db #00,#00,#bc,#86,#53,#24,#f6,#cc
	db #a4,#7e,#5a,#38,#18,#fa,#00,#00
	db #00,#00,#de,#c3,#aa,#92,#7b,#66
	db #52,#3f,#2d,#1c,#0c,#fd,#00,#00
	db #00,#00,#ef,#e1,#d5,#c9,#be,#b3
	db #a9,#9f,#96,#8e,#86,#7f,#00,#00
	db #00,#00,#77,#71,#6a,#64,#5f,#59
	db #54,#50,#4b,#47,#43,#3f,#00,#00
	db #00,#00,#3c,#38,#35,#32,#2f,#2d
	db #2a,#28,#26,#24,#22,#20,#00,#00
	db #00,#00,#1e,#1c,#1b,#19,#18,#16
	db #15,#14,#13,#12,#11,#10,#00,#00
.l24d2 equ $ + 2
	db #00,#00,#0e,#0e,#0d,#0c,#0b,#0b
	db #0a,#09,#09,#08,#08,#07,#00,#00
	db #00,#00,#07,#07,#06,#06,#05,#05
	db #05,#04,#04,#04,#04,#03,#00,#00
	db #00,#00,#03,#03,#03,#03,#02,#02
	db #02,#02,#02,#02,#02,#01,#00,#00
	db #00,#00,#01,#01,#01,#01,#01,#01
	db #01,#01,#01,#01,#01,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00
;
.init_music	; added by Megachur
;
	call real_init_music
	ld hl,evt_bloc
	ld bc,#8100
	ld de,play_music
	jp #bcd7	; call play_music every CRT interrupt
evt_bloc
	db #00,#00,#00,#00,#00,#00
	db #00,#00,#00	
;org #0e1d
;call #560b	; init
;.l0e20
;call #bd19
;call #5600	; play
;call #bb1b
;jr nc,l0e20
;
.game_name
	db "Ninja Hamster",0
.game_year
	db "1987",0
.game_publisher
	db "CRL",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
